/*
 * Filename AlgoClient.java 2021年09月26日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 * @author wuyingchao
 */
package com.ehome.poct.core.service.rpc;

import cn.hutool.core.lang.Tuple;
import com.ehome.feign.annotation.IgnoreFeignResponseAdvice;
import com.ehome.poct.core.api.dto.check.CellAlgoAnalysisDTO;
import com.ehome.poct.core.api.dto.check.GoldCheckAlgoReqDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.net.URI;

/**
 * 算法 rpc
 *
 * @author wyc
 * @since 2021/09/26 16:34
 **/
@Component
@RefreshScope
@RequiredArgsConstructor
public class GoldAlgoRpcImpl implements GoldAlgoRpc {
    private final GoldAlgoClient algoClient;
    @Value("${algo.baseURL}")
    private String algoUrl;

    @Override
    public String getAlgoResultData(GoldCheckAlgoReqDTO reqDTO) {
        return algoClient.getAlgoResultData(URI.create(algoUrl), reqDTO);
    }


    @FeignClient(value = "algo", contextId = "algo", url = "http://algo")
    interface GoldAlgoClient {

        /**
         * 获取算法接口（金标仪）返回的数据
         *
         * @param reqDTO
         * @return
         */
        @PostMapping("/getResultData")
        @IgnoreFeignResponseAdvice
        String getAlgoResultData(URI uri, @RequestBody GoldCheckAlgoReqDTO reqDTO);


    }
}